/*
** cpy_word.c for 42sh in /home/lamais_a//minishell2-2017-lamais_a
** 
** Made by adrien lamaison
** Login   <lamais_a@epitech.net>
** 
** Started on  Sat Jun 15 09:14:14 2013 adrien lamaison
** Last update Sat Jun 15 13:07:43 2013 adrien lamaison
*/

#include "minishell.h"

char	*cpy_str(char *dest, char *str, int *count)
{
  int	count2;

  count2 = 0;
  while (my_char_simple(str[*count]) != 1 && my_char_double(str, *count) != 1
	 && str[*count] != 0)
    {
      dest[count2] = str[*count];
      (*count)++;
      count2++;
    }
  return (dest);
}

t_redirection	*cpy_double(t_redirection *my_redirection, char *str, 
			    int *count, int word)
{
  my_redirection->redirection[word] = malloc(3 * sizeof(char));
  if (my_redirection->redirection[word] == NULL)
    return (NULL);
  my_redirection->redirection[word][0] = str[*count];
  my_redirection->redirection[word][1] = str[(*count) + 1];
  my_redirection->redirection[word][2] = 0;
  (*count) += 2;
  return (my_redirection);
}

t_redirection	*cpy_simple(t_redirection *my_redirection, char *str, 
			    int *count, int word)
{
  my_redirection->redirection[word] = malloc(2 * sizeof(char));
  if (my_redirection->redirection[word] == NULL)
    return (NULL);
  my_redirection->redirection[word][0] = str[*count];
  my_redirection->redirection[word][1] = 0;
  (*count)++;
  return (my_redirection);
}
